/*NOTICE

This software was produced for the U. S. Government
under Contract No. FA8721-09-C-0002, and is
subject to the Rights in Noncommercial Computer Software
and Noncommercial Computer Software Documentation Clause
(DFARS) 252.227-7014 (JUN 1995)

(c) 2009 The MITRE Corporation. All Rights Reserved.
*/
package org.mitre.xmltransform.spmif;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.mitre.xmltransform.XmlInputDocument;
import org.mitre.xmltransform.XmlOutputDocument;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public abstract class HierarchyStep {
	public HierarchyStep(String pId, String pExecId, Node pNode, String pNodeName, XmlInputDocument pInput, XmlOutputDocument pOutput) {
		mId = pInput.buildNodeName(pNode, getIdPrefix()); //pId;
		mExecId = pExecId;
		mNode = pNode;
		mNodeName = pNodeName;
		mChildren = new ArrayList<HierarchyStep>();
		mInput = pInput;
		mOutput = pOutput;
		mDuration = null;
	}
	
	public abstract String getIdPrefix();
	
	public String getStartNodeName() {
		//return buildEventOccurrenceNodeName(getNode());
		return mNodeName;
	}
	
	public String getStartNodeId() {
		return mId;
	}
	
	public void addChild(HierarchyStep pChild) {
		mChildren.add(pChild);
	}
	
	public String getExecId() {
		return mExecId;
	}
	
	public String getId() {
		return mId;
	}
	
	public Node getNode() {
		return mNode;
	}
	
	public String getNodeName() {
		return mNodeName;
	}
	
	public boolean hasChildren() {
		return !mChildren.isEmpty();
	}
	public Iterator<HierarchyStep> getChildren() {
		return mChildren.iterator();
	}
	
	public abstract void generateStep(Element pParentElement, Device pLocation);
	public abstract String generateArcs(Element pParentElement, String pFromNode);
	public void setLocation(Device pLocation) {
		mLocation = pLocation;
	}
	public Device getLocation() {
		return mLocation;
	}
	public void setDuration(String pDuration) {
		mDuration = pDuration;
	}
	public String getDuration() {
		return mDuration;
	}
	
	private Device mLocation;
	private String mDuration;
	protected XmlOutputDocument mOutput;
	protected XmlInputDocument mInput;
	private List<HierarchyStep> mChildren;
	private String mId;
	private String mExecId;
	private Node mNode;
	private String mNodeName;
}
